package com.breeze.components.core.util.json.serializer;

import cn.hutool.core.net.Ipv4Util;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;

/**
 * 根据long值获取ip v4地址：xx.xx.xx.xx
 *
 * @author breeze
 */
public class Ipv4LongStringSerializer extends JsonSerializer<Long> {
  @Override
  public void serialize(Long value, JsonGenerator gen, SerializerProvider serializers)
      throws IOException {
    gen.writeString(Ipv4Util.longToIpv4(value));
  }
}
